/**
 * This script is very simple.  It is run in every frame. If a content-pane exists in that frame, it sends the
 * URL of that frame to background.html.  It then waits for a message which tells it where to scroll.
 */
var pane = document.getElementById( "content-pane" );
if( !pane && document.getElementById( "viewport" ) ) pane = document.getElementById( "viewport" ).firstChild;

// Move everything into this block so that the objects don't even exist if it is not a PDF document
if( pane )
{
   var port    = chrome.extension.connect();
   var currLoc = window.location.href;
   var mess    = {href: currLoc, action:"receive"};
   port.postMessage(mess);
   
   port.onMessage.addListener(function(msg) {
      if( !isNaN( msg.scrollTop ) && msg.href == currLoc ) pane.scrollTop = msg.scrollTop;
   });
}

